<?php
namespace app\api\controller;
use app\model\MotifModel;
use app\model\TopicModel;
use think\facade\Request;

class preview{
    public function preview_list(){
        session_start();
        $motifid = $_SESSION['motif_id'];

        $motif = MotifModel::find($motifid);
        $topic = TopicModel::where('motif_id','=',$motifid)->select();

        $topicMany = [];
        foreach($topic as $key => $value){
            $topicMany[$key][] = $value['topic_id'];
            $topicMany[$key][] = $value['topic_name'];
            $topicMany[$key][] = $value['score_right'];
            $topicMany[$key][] = $value['score_lift'];
        }

        $data = [
            'status' => 0,
            'message' => '',
            'data' => [
                $motif['motif_them'],
                $topicMany,
                $motifid
                ]
        ];
        return json($data);

    }
}